package com.example.nbb.Controller;


import com.example.nbb.Service.CollectionService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@CrossOrigin//跨域
@RestController//遵循RestFul
@RequestMapping("/nbb/Collection/")
public class CollectionController {

    @Resource
    CollectionService collectionService;

    @GetMapping("getAll")
    public String getAll(@RequestParam("userId") int userId) {
        return collectionService.selectAll(userId);
    }

    @PostMapping("addCollection")
    public String addCollection(@RequestParam("userId") int userId, @RequestParam("productId") int productId) {
        return collectionService.addCollection(userId, productId);
    }

    @PostMapping("deleteCollection")
    public String deleteCollection(@RequestParam("collectionId") int collectionId) {
        return collectionService.deleteCollection(collectionId);
    }
}
